﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>独立的流程</title>
    <link href="../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <script src="DDLBar.js" type="text/javascript"></script>

    <link href="../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
    <link href="../../Style/skin/css/Default.css" rel="stylesheet" />
    <script src="../EnumLab.js"></script>
    <script type="text/javascript">

        var entityType = 2;
        var frmTreeNo = "";
        var module = null;
        var moduleNo = null;
        $(function () {

            moduleNo = GetQueryString("ModuleNo");

            //设置树的编号,树的编号与系统编号一致.
            module = new Entity("BP.CCFast.CCMenu.Module", moduleNo);
            frmTreeNo = module.SystemNo;

            InitBar(MenuModel.StandAloneFlow);

            //初始化下拉框
            InitBarFlow();

        });

        function Save() {

            $("#Msg").html("正在创建,请稍后......");

            var name = document.getElementById("TB_Name").value;
            if (name == "") {
                $("#Msg").html("");
                alert('@名称不能为空.');
                return;
            }

            var flowDevModel = $("#DDL_FlowModel").val();

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_GPM_CreateMenu");
            handler.AddPara("SortNo", module.SystemNo); //模块的系统编号，也是流程目录的编号
            handler.AddPara("FlowName", name);
            handler.AddPara("FlowDevModel", flowDevModel); //流程模式.
            moduleNo = GetQueryString("ModuleNo");
            handler.AddPara("ModuleNo", moduleNo); //模块编号.
            var flowNo = handler.DoMethodReturnString("StandAloneFlow_Save");

            if (flowNo.indexOf('err@') >= 0) {
                $("#Msg").html("<font color=red>" + flowNo + "</font>");
                return;
            }

            $("#Msg").html("<font color=green>流程已经创建，正在创建菜单与菜单目录。</font>");

            var en = new Entity("BP.CCFast.CCMenu.Menu");
            en.MenuModel = MenuModel.StandAloneFlow; //模式.
            en.ModuleNo = module.No; //隶属的模块.
            en.SystemNo = module.SystemNo; //系统编号.

            en.Name = name; //流程名称.
            en.UrlExt = "/CCFast/StandAloneFlow/Default.htm?FK_Flow=" + flowNo + "&ModuleNo=" + module.No;
            en.Mark = "StartFlow"; //标记.
            en.Tag1 = flowNo; //编号.
            en.No = en.Mark + "_" + flowNo;
            en.Icon = "icon-paper-plane";
            en.Idx = 0;
            en.Insert();

            SetHref("../../Comm/En.htm?EnName=BP.CCFast.CCMenu.Menu&No=" + en.No);
            //  alert("创建成功，您可以在在菜单里执行高级编辑与授权.");
            //  SetHref( "../Menus.htm";
            // window.close();
        }

        function InitBarFlow() {

            var optionKey = 0;

            var html = "";
            html += "<select id='DDL_FlowModel' >";
            var groups = GetDBGroupFlow();
            var dtls = GetDBDtlFlow();

            for (var i = 0; i < groups.length; i++) {

                var group = groups[i];
                html += "<option value=null  disabled='disabled'>+" + group.Name + "</option>";

                for (var idx = 0; idx < dtls.length; idx++) {
                    var dtl = dtls[idx];
                    if (dtl.GroupNo != group.No)
                        continue;
                    html += "<option value=" + dtl.No + ">&nbsp;&nbsp;" + dtl.Name + "</option>";
                }
            }
            html += "</select>";
            document.getElementById("Model").innerHTML = html;
            $("#changBar option[value='" + optionKey + "']").attr("selected", "selected");
        }

        function GenerPinYin() {

            //是否是全拼.
            var isQuanPin = 0;
            if (document.getElementById("RB_ZZMM_0").checked == true)
                isQuanPin = 1;

            // var name = $('#TB_Nam').val();
            var name = document.getElementById("TB_Name").value;
            if (name == "")
                return;

            var handler = new HttpHandler("BP.WF.HttpHandler.Admin_CCFormDesigner");
            handler.AddPara("IsQuanPin", isQuanPin);
            handler.AddPara("TB_Name", encodeURIComponent(name));
            var data = handler.DoMethodReturnString("NewFrmGuide_GenerPinYin");

            $("#Msg").html("");

            if (data.indexOf('err@') >= 0) {
                $("#Msg").html("<font color=red>" + data + "</font>");
                return;
            }
            var webUser = new WebUser();
            var keyOrg = webUser.FK_Dept + "_CCFrm_" + data;
            var key = "CCFrm_" + data;

            var frmType = $("#DDL_FrmType").val();
            if (frmType != "3" && frmType != "7") {

                if (entityType == 0)
                    key = "Frm_" + data;
                if (entityType == 1)
                    key = "Bill_" + data;
                if (entityType == 2)
                    key = "Dict_" + data;
                keyOrg = webUser.OrgNo + "_" + key;
            }


            $('#TB_No').val(key);
            $('#TB_PTable').val(key);
            // 没有高明白.
            //   $('#TB_No_Org').val(keyOrg);
            //   $('#TB_PTable_Org').val(keyOrg);
            return;
        }

        function GetDBGroupFlow() {

            var json = [

                { "No": "A", "Name": "内置表单模式" },
                //{ "No": "B", "Name": "服务的模式" },
                { "No": "C", "Name": "绑定表单库模式" },
                { "No": "D", "Name": "自定义表单模式" },
                { "No": "E", "Name": "物联网流程模式" },
                { "No": "F", "Name": "敏捷应用" }

            ];
            return json;
        }

        function GetDBDtlFlow() {

            var json = [

                { "No": 0, "Name": "专业模式", "GroupNo": "A", "Url": "0.Prefessional.htm" },
                { "No": 1, "Name": "极简模式", "GroupNo": "A", "Url": "1.JiJian.htm" },
                { "No": 2, "Name": "累加表单", "GroupNo": "A", "Url": "2.FoolTruck.htm" },

                { "No": 3, "Name": "绑表单库的表单", "GroupNo": "C", "Url": "3.RefOneFrmTree.htm" },
                { "No": 4, "Name": "表单树", "GroupNo": "C", "Url": "4.FrmTree.htm" },

                { "No": 5, "Name": "SDK表单", "GroupNo": "D", "Url": "5.SDKFrm.htm" },
                { "No": 6, "Name": "嵌入式表单", "GroupNo": "D", "Url": "6.SelfFrm.htm" },


                { "No": 7, "Name": "物联网流程", "GroupNo": "E", "Url": "7.InternetOfThings.htm" },
                { "No": 8, "Name": "决策树模式", "GroupNo": "E", "Url": "8.Tree.htm" },


                { "No": 9, "Name": "实体(车辆、固定资产)", "GroupNo": "F", "Url": "9.Dict.htm" },
                { "No": 10, "Name": "单据(车辆维修记录、固资使用记录)", "GroupNo": "F", "Url": "10.Bill.htm" }
            ];
            return json;
        }
    </script>
</head>
<body>
    <form id="CCForm">
        <div id="bar">
        </div>
        <fieldset>
            <legend>创建流程</legend>
            <table>
                <tr>
                    <td>流程名称 </td>
                    <td>  <input type="text" value="" id="TB_Name" name="TB_Name" /></td>
                </tr>

                <tr>
                    <td>模式 </td>
                    <td>
                        <div id="Model">
                        </div>
                    </td>
                </tr>
            </table>

            <div id="Msg"></div>
        </fieldset>

        <fieldset>
            <legend id="help">帮助</legend>
            <ul>
                <li> 创建流程后，系统自动对该流程的相关操作创建到菜单上去。 </li>
                <li> 比如：发起流程，流程查询、分析。 </li>
            </ul>

            <legend>流程图</legend>
            <ul>
                <li> <img src="StandAloneFlow.png" style="width:50%;" class="HelpImg" /></li>
            </ul>
        </fieldset>
    </form>
</body>
</html>
